﻿using H.Types;
using System.Drawing;
using System.Windows.Forms;

namespace H.Kernel.Utils
{
    public class RectUtils
    {
        /// <summary>
        /// 获取表示全屏的矩形区域
        /// </summary>
        /// <returns></returns>
        public static Rect GetFullScreenRect()
        {
            Rectangle fullrect = Screen.PrimaryScreen.Bounds;

            //全屏的矩形
            return new Rect(fullrect.X, fullrect.Y, fullrect.Width, fullrect.Height);
        }

        /// <summary>
        /// 获取不包含任务栏的矩形区域
        /// </summary>
        /// <returns></returns>
        public static Rect GetWorkAreaRect()
        {
            Rectangle workrect = Screen.PrimaryScreen.WorkingArea;

            //全屏的矩形
            return new Rect(workrect.X, workrect.Y, workrect.Width, workrect.Height);
        }


        /// <summary>
        /// 获取任务栏的矩形区域
        /// </summary>
        /// <returns></returns>
        public static Rect GetTaskBarRect()
        {
            Rectangle all = Screen.PrimaryScreen.Bounds;
            Rectangle taskBar = Screen.PrimaryScreen.WorkingArea;
            //MessageBox.Show($"all:{all}\r\ntaskBar:{taskBar}");

            int x = all.X == taskBar.X ? all.Width - taskBar.Width : 0;
            int y = all.Y == taskBar.Y ? all.Height - taskBar.Height : 0;
            int width = all.Width == taskBar.Width ? all.Width : all.Width - taskBar.Width;
            int height = all.Height == taskBar.Height ? all.Height : all.Height - taskBar.Height;
            //MessageBox.Show($"result:{new Rect(x, y, width, height)}");
            return new Rect(x, y, width, height);
        }
    }
}
